package com.spddr.pmos.jpa;

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Embeddable;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Embeddable
public class UnitNhqId implements java.io.Serializable {
	private static final long serialVersionUID = 1L;

	private long unit;
	private BigDecimal dropHeight;
	private BigDecimal power;

	public UnitNhqId() {
	}

	public UnitNhqId(long unit, BigDecimal dropHeight, BigDecimal power) {
		this.unit = unit;
		this.dropHeight = dropHeight;
		this.power = power;
	}

	@JsonIgnore
	@Column(name = "unit", nullable = false)
	public long getUnit() {
		return this.unit;
	}

	public void setUnit(long unit) {
		this.unit = unit;
	}

	@Column(name = "drop_height", nullable = false, precision = 5)
	public BigDecimal getDropHeight() {
		return this.dropHeight;
	}

	public void setDropHeight(BigDecimal dropHeight) {
		this.dropHeight = dropHeight;
	}

	@Column(name = "power", nullable = false, precision = 5, scale = 1)
	public BigDecimal getPower() {
		return this.power;
	}

	public void setPower(BigDecimal power) {
		this.power = power;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((dropHeight == null) ? 0 : dropHeight.hashCode());
		result = prime * result + ((power == null) ? 0 : power.hashCode());
		result = prime * result + (int) (unit ^ (unit >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		UnitNhqId other = (UnitNhqId) obj;
		if (dropHeight == null) {
			if (other.dropHeight != null)
				return false;
		} else if (!dropHeight.equals(other.dropHeight))
			return false;
		if (power == null) {
			if (other.power != null)
				return false;
		} else if (!power.equals(other.power))
			return false;
		if (unit != other.unit)
			return false;
		return true;
	}
}